//
//  ParleysObject.m
//  ipadclient
//
//  Created by Stéphane Prohaszka on 03/06/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "ParleysSection.h"


@implementation ParleysSection

@synthesize identification;
@synthesize keywords;
@synthesize thumbnail;
@synthesize description;
@synthesize name;

- (id) init {
    self = [super init];
    
    if (self) {
        identification = 0;
        thumbnail = nil;
        keywords = [[NSMutableSet alloc] init];
        description = nil;
        name = nil;
    }
    
    return self;
}

- (id) initWithJson:(NSDictionary*)jsonObject {
    self = [super init];
    
    if (self) {
        identification = [[jsonObject objectForKey:@"id"] intValue];
        thumbnail = [[jsonObject objectForKey:@"thumbnail"] retain];
        keywords = [[NSMutableSet alloc] init];
        description = [[jsonObject objectForKey:@"description"] retain];
        name = [[jsonObject objectForKey:@"name"] retain];
    }
    
    return self;
}

- (id)initWithCoder:(NSCoder *)aDecoder {
    self = [super init];
    
    if (self) {
        identification = [aDecoder decodeIntForKey:@"identification"];
        thumbnail = [aDecoder decodeObjectForKey:@"thumbnail"];
        keywords = [aDecoder decodeObjectForKey:@"keywords"];
        description = [aDecoder decodeObjectForKey:@"description"];
        name = [aDecoder decodeObjectForKey:@"name"];
    }
    
    return self;
}

- (void)dealloc {
    [thumbnail release];
    [keywords release];
    [description release];
    [name release];
    [super dealloc]; 
}

- (id)copyWithZone:(NSZone *)zone {
    ParleysSection* copy = [[[self class] allocWithZone:zone] init];
    copy.identification = self.identification;
    copy.thumbnail = [self.thumbnail copyWithZone:zone];
    copy.keywords = [self.keywords copyWithZone:zone];
    copy.description = [self.description copyWithZone:zone];
    copy.name = [self.name copyWithZone:zone];
    
    return copy;
}

- (void)encodeWithCoder:(NSCoder *)aCoder {
	[aCoder encodeInt:identification forKey:@"identification"];
	[aCoder encodeObject:thumbnail forKey:@"thumbnail"];
	[aCoder encodeObject:keywords forKey:@"keywords"];
	[aCoder encodeObject:description forKey:@"description"];
	[aCoder encodeObject:name forKey:@"name"];
}

@end
